<?php require("../../Connections/cotiza.php"); ?>
<?php 

	mysql_select_db($database_cotiza);
	$capa  = $_GET['capa'];
	$mat   = $_GET['mat'];
	$valor = $_GET['valor'];
	$pct   = $_GET['pct'];
	$solic = $_GET['solic'];
	
	if($pct <> "")
		$query = "INSERT INTO mat_capa(matc_mat_id,matc_capa,matc_solic_id,matc_pct_espesor) VALUES('LEROLERO',$capa,'$solic',$pct) ON DUPLICATE KEY UPDATE matc_pct_espesor = $pct";
	
	if($capa <> "" && $mat <> "" && $valor <> "" && $pct == "")
		$query = "INSERT INTO matcd_det(matcd_capa,matcd_mat_id,matcd_pt_id,matcd_pct) VALUES($capa,'LEROLERO','$mat',$valor) ON DUPLICATE KEY UPDATE matcd_pct = $valor";
	
	if($capa <> "" && $mat <> "" && $valor == "" && $pct == "")
		$query = "DELETE FROM matcd_det WHERE matcd_capa = $capa AND matcd_mat_id = 'LEROLERO' and matcd_pt_id = '$mat'";

	mysql_query($query,$cotiza); //or die(mysql_error());
?>
<?php 
mysql_close($cotiza);
?>